{[{define "system/nav/add.html"}]}
<style>
    .layui-iconpicker-body.layui-iconpicker-body-page .hide {
        display: none;
    }
</style>
<link rel="stylesheet" href="/static/admin/css/public.css" media="all">
<link rel="stylesheet" href="/static/plugs/lay-module/layuimini/layuimini.css" media="all">
<link rel="stylesheet" href="/static/plugs/lay-module/layuimini/themes/default.css" media="all">
<div class="layuimini-container">


    <form id="app-form" class="layui-form layuimini-form">

        <div class="layui-form-item">
            <label class="layui-form-label ">标题</label>
            <div class="layui-input-block">
                <input type="text" name="Title" class="layui-input" lay-verify="" lay-reqtext="请输入标题" placeholder="请输入标题" value="">
                <tip>填写标题。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label ">图片</label>
            <div class="layui-input-block layuimini-upload">
                <input name="ImageUrl" id="path_" class="layui-input layui-col-xs6" lay-verify="" lay-reqtext="请上传文件" placeholder="请上传文件" value="">
                <div class="layuimini-upload-btn">
                    <span><a class="layui-btn" data-upload="image_url" data-upload-number="one" data-upload-exts="png|jpg|ico|jpeg"><i class="fa fa-upload"></i> 上传文件</a></span>
                    <span ><a class="layui-btn layui-btn-normal" id="chan_pic"><i class="fa fa-list"></i> 选择文件</a></span>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label ">热门图标</label>
            <div class="layui-input-block layuimini-upload">
                <input name="HotUrl" id="hot_url" class="layui-input layui-col-xs6" lay-verify="" lay-reqtext="请上传文件" placeholder="请上传文件" value="">
                <div class="layuimini-upload-btn">
                    <span><a class="layui-btn" data-upload="hot_url" data-upload-number="one" data-upload-exts="png|jpg|ico|jpeg"><i class="fa fa-upload"></i> 上传文件</a></span>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label ">链接地址</label>
            <div class="layui-input-block">
                <input type="text" name="LinkUrl" class="layui-input" lay-verify="" lay-reqtext="请输入链接地址" placeholder="请输入链接地址" value="">
                <tip>填写链接地址。</tip>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea name="Description" class="layui-textarea" placeholder="请输入描述"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否登录</label>
            <div class="layui-input-block">
                <input type="radio" name="Islogin" value="0" title="否" checked >
                <input type="radio" name="Islogin" value="1" title="是" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否vip</label>
            <div class="layui-input-block">
                <input type="radio" name="Vip" value="0" title="否"  checked>
                <input type="radio" name="Vip" value="1" title="是"  >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="int"  name="Px" class="layui-input" lay-verify="" lay-reqtext="请输入排序" placeholder="请输入排序" value="100">
                <tip>填写排序。</tip>
            </div>
        </div>

        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="add">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>
    </form>

</div>
<script src="/static/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/static/layuimini/js/lay-config.js" charset="utf-8"></script>
<script>

    layui.use(['form', 'jquery','sh'], function () {
        var $ = layui.jquery,
            form = layui.form,
            sh = layui.sh;
            sh.api.upload();



            form.on('submit(add)', function (data) {
                data = data.field;
                sh.request.post(
                    {
                        url: '/system/nav/add_ajax',
                        data: data,
                    }, function (res) {
                        console.log(res)
                        if (res.code == 200) {
                            sh.msg.success('添加成功', function () {
                                window.parent.location.reload();//刷新父页面
                                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                                parent.layer.close(index);
                            });
                        } else {
                            sh.msg.error(data.msg, {icon: 2});
                        }
                    }
                );
                return false;
            });


        $('#chan_pic').click(function () {
            layer.open({
                title:"选择素材图片",
                type: 2,
                area: ["80%", "90%"],
                offset:'auto',
                maxmin : true,
                skin:'layui-layer-rim',
                shade: 0.5,
                content: "/system/upload/flist",
                success:function(){
                    setTimeout(function(){
                        layui.layer.tips('点击此处返回列表', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3,time:1000
                        });
                    },500)
                },
                end:function () {
                    if (typeof(mFsUrls) != "undefined" && mFsUrls.length > 0) {
                        $("#path_").val(mFsUrls);
                        $(".path_").attr("src",mFsUrls);
                    }
                }
            });
            return false;
        });

    });

</script>
{[{end}]}

